package com.sx.micowell.module.user.writeInfo

import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.mvvm.base.data.DataBindingConfig
import com.example.mvvm.until.LogUtils
import com.example.mvvm.until.ToastUtils
import com.gyf.immersionbar.ImmersionBar
import com.sx.micowell.BR
import com.sx.micowell.R
import com.sx.micowell.databinding.ActWriteHeightBinding
import com.sx.micowell.framework.app.IntentKey
import com.sx.micowell.framework.app.MyActivity
import com.sx.micowell.framework.arouth.RouteManager
import com.sx.micowell.framework.arouth.RoutePath.Companion.WRITE_HEIGHT
import com.sx.micowell.framework.model.PhysicalInfoModel

/**
 * @Description
 * @Author 梁浩文
 * @Date 2021/7/29 16:31
 */
@Route(path = WRITE_HEIGHT)
class WriteHeightActivity : MyActivity<ActWriteHeightBinding>() {

    @Autowired(name = IntentKey.TYPE)
    @JvmField
    var type: String = ""

    @Autowired(name = IntentKey.DATA)
    @JvmField
    var date: String = ""

    private var height: String = ""

    private var viewMode: PhysicalInfoModel?=null

    override fun getDataBindingConfig(): DataBindingConfig = DataBindingConfig(R.layout.act_write_height, BR.viewModel, viewMode)

    override fun initViewModel() {
        super.initViewModel()
        viewMode=getActivityScopeViewModel(PhysicalInfoModel::class.java)
    }

    override fun initView() {
        ImmersionBar.with(this).statusBarDarkFont(true)
            .fitsSystemWindows(true).init()

        if (type == "0") {
            binding.imagePerson.setImageResource(R.drawable.bg_boy_big)
        } else {
            binding.imagePerson.setImageResource(R.drawable.bg_girl_big)
        }

        binding.tvNext.setOnClickListener {
            height = binding.rulerWeight.heightValue
            if (height == "0") {
                ToastUtils.showShort("请选择身高")
                return@setOnClickListener
            }
            LogUtils.d("setOnClickListener: $height")
            RouteManager.getInstance().intentToWeight(type, date, height)
        }
    }

    override fun initData() {
    }
}